package com.ruoyi.test_emp.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.test_emp.domain.TestEmp;
import com.ruoyi.test_emp.service.ITestEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工测试Controller
 * 
 * @author ruoyi
 * @date 2021-10-03
 */
@RestController
@RequestMapping("/test_emp/emp")
public class TestEmpController extends BaseController
{
    @Autowired
    private ITestEmpService testEmpService;

    /**
     * 查询员工测试列表
     */
    @PreAuthorize("@ss.hasPermi('test_emp:emp:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestEmp testEmp)
    {
        startPage();
        List<TestEmp> list = testEmpService.selectTestEmpList(testEmp);
        return getDataTable(list);
    }

    /**
     * 导出员工测试列表
     */
    @PreAuthorize("@ss.hasPermi('test_emp:emp:export')")
    @Log(title = "员工测试", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TestEmp testEmp)
    {
        List<TestEmp> list = testEmpService.selectTestEmpList(testEmp);
        ExcelUtil<TestEmp> util = new ExcelUtil<TestEmp>(TestEmp.class);
        return util.exportExcel(list, "员工测试数据");
    }

    /**
     * 获取员工测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('test_emp:emp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(testEmpService.selectTestEmpById(id));
    }

    /**
     * 新增员工测试
     */
    @PreAuthorize("@ss.hasPermi('test_emp:emp:add')")
    @Log(title = "员工测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestEmp testEmp)
    {
        return toAjax(testEmpService.insertTestEmp(testEmp));
    }

    /**
     * 修改员工测试
     */
    @PreAuthorize("@ss.hasPermi('test_emp:emp:edit')")
    @Log(title = "员工测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestEmp testEmp)
    {
        return toAjax(testEmpService.updateTestEmp(testEmp));
    }

    /**
     * 删除员工测试
     */
    @PreAuthorize("@ss.hasPermi('test_emp:emp:remove')")
    @Log(title = "员工测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(testEmpService.deleteTestEmpByIds(ids));
    }
}
